﻿namespace AgileBoard.Infrastructure.Data.Repositories
{
    using System.Collections;
    using Domain;
    using Domain.DataInterfaces;
    using SharpArch.Data.NHibernate;

    public class RoleRepository : Repository<Role>, IRoleRepository
    {
        #region IRoleRepository Members

        public Role FindByName(string roleName)
        {
            IList role = Session.CreateQuery("from Role where Name = :roleName")
                .SetParameter("roleName", roleName)
                .List();

            if (role != null && role.Count > 0)
                return role[0] as Role;

            return null;
        }

        public Role FindById(int? roleId)
        {
            IList role = Session.CreateQuery("from Role where RoleID = :roleId")
                .SetParameter("roleId", roleId)
                .List();

            if (role != null && role.Count > 0)
                return role[0] as Role;

            return null;
        }

        #endregion
    }
}